package com.lyf.scm.admin.domain.remote.stock.facade;

import com.github.pagehelper.PageInfo;
import com.lyf.scm.admin.domain.remote.basedata.dto.StoreDTO;
import com.lyf.scm.admin.domain.remote.stock.dto.RealWarehouseDTO;
import com.lyf.scm.admin.domain.remote.stock.StockCenterRemote;
import com.lyf.scm.common.enums.ResponseMsg;
import com.rome.arch.core.clientobject.Response;
import com.rome.arch.core.exception.RomeException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 基本数据外观
 *
 * @author wuzhuang
 * @date 2020/06/30
 */
@Service
public class StockFacade {

    @Resource
    private StockCenterRemote stockCenterRemote;

    public PageInfo<RealWarehouseDTO> getAllWarehouse(RealWarehouseDTO realWarehouseDTO) {
        Response<PageInfo<RealWarehouseDTO>> response = stockCenterRemote.getAllWarehouse(realWarehouseDTO);
        if (!ResponseMsg.SUCCESS.getCode().equals(response.getCode())) {
            throw new RomeException(response.getCode(), response.getMsg());
        }
        return response.getData();
    }

    public List<StoreDTO> queryFactoryByRwType(Integer realWarehouseType) {
        Response<List<StoreDTO>> response = stockCenterRemote.queryFactoryByRwType(realWarehouseType);
        if (!ResponseMsg.SUCCESS.getCode().equals(response.getCode())) {
            throw new RomeException(response.getCode(), response.getMsg());
        }
        return response.getData();
    }
}
